#include "RingQueue.hpp"
#include <unistd.h>

void* routine_consumer(void* arg)
{
    ring_queue<int>* rq = (ring_queue<int>*)arg;
    while(true)
    {
        rq->pop();
        std::cout << "消费一个data" << std::endl;
    }
}

void* routine_productor(void* arg)
{
    ring_queue<int>* rq = (ring_queue<int>*)arg;
    int data = 0;
    while(true)
    {
        //sleep(1);
        rq->push(data++);
        std::cout << "生产一个data: " << data << std::endl;
    }
}


int main()
{
    ring_queue<int>* rq = new ring_queue<int>;

    pthread_t consumer, productor;
    pthread_create(&consumer, nullptr, routine_consumer, rq);
    pthread_create(&productor, nullptr, routine_productor, rq); 

    pthread_join(consumer, nullptr);
    pthread_join(productor, nullptr);

    return 0;
}